#include <stdio.h>

int main () {
    int matrix[100][100] = {0}, n, k, x, i, j, l, tmp, down = 0, sum = 0, output = 0;
    scanf("%d%d%d", &n, &k, &x);
    for ( i = 0; i < n; i++ ) {
        for ( j = 0; j < n; j++ ) {
            scanf("%d", &matrix[i][j]);
        }
    }
    for ( j = 1; j < n; j+=2 ) {
        down++;
        if ( down > k ) down = 1;
        for ( l = 0; l < down; l++ ) {
            for ( i = n-1-l; i >= down; i-=down ) {
                matrix[i][j] = matrix[i-down][j];
            }
        }
        for ( i = 0; i < down; i++ ) matrix[i][j] = x;
    }
    for ( i = 0; i < n; i++ ) {
        for ( j = 0; j < n; j++ ) {
            sum+=matrix[i][j];
            // printf("%d ", matrix[i][j]);
        }
        if ( output == 0 ) {
            printf("%d", sum);
            output = 1;
        } else printf(" %d", sum);
        sum = 0;
        // printf("\n");
    }
    printf("\n");
    return 0;
}